#coding=utf-8

require "aio/core"

class Aio::Module::Cmd::Maipu::ShowIpRouteStat < Aio::Module::Cmd::Maipu
	include Aio::Module
	
	def initialize
		super({
			:cmd_full			=> "show ip route statistic",
			:cmd_short		=> "sh ip rou stat",
			:author				=> "Elin",
			:description	=> "This is Maipu Command# show ip route statistic",
			:ranking			=> Ranking_1,
			:platform			=> "all",
			:benchmark		=> {}
		})
	end

	def parse
		cont = self.context.dup
		stat = {}
		useful[:route_summary] = stat

		cont.readline_match_block(/Statistics for the route/) {|b|b}

		cont.readline_match_block_loop(/(?<proto>[^s]+) (?<count>\d+)/, reg_blank) do |block|
			route = {}
			proto = block[:proto].strip
			useful[:route_summary][proto.to_sym] = route
			block.update(route, :proto)
			block.update(route, :count)
		end

	end
end
